package com.dapeng.net;

import java.io.FileNotFoundException;
import java.io.RandomAccessFile;

public class RandomAccessFileTest {


    public static void main(String[] args) throws Exception {
        RandomAccessFile raf = new RandomAccessFile("d://xxoo.txt", "rw");
        String line1 = "中文\n";
        byte[] b1 = line1.getBytes();

        System.out.println("b1.length : " + b1.length);
        raf.write(b1);
        String line2 = "english\n";
        byte[] b2 = line2.getBytes();
        System.out.println("b2.length : " + b2.length);
        raf.write(b2);

        raf.seek(7);
        byte[] b3 = new byte[8];
        raf.read(b3, 0, 8);
        System.out.println(new String(b3));


    }
}
